package com.zhkj.txg.module.order.ui

import android.content.Context
import android.view.Gravity
import android.view.View
import android.widget.TextView
import com.zhkj.txg.R
import razerdp.basepopup.BasePopupWindow

class SimplePopupWindow(context: Context) : BasePopupWindow(context) {

    init {
        popupGravity = Gravity.CENTER
    }

    private var clickListener: OnItemClickListener? = null

    override fun onCreateContentView(): View = createPopupById(R.layout.popup_receive_confirm)
    override fun onViewCreated(contentView: View?) {
        findViewById<View>(R.id.tvUserNicknameConfirm).setOnClickListener {
            clickListener?.onClick(this)
        }
        findViewById<View>(R.id.tvUserNicknameCancel).setOnClickListener { dismiss() }
    }

    fun setTitle(title: String): SimplePopupWindow {
        findViewById<TextView>(R.id.tvTitle).text = title
        return this
    }

    fun setContent(content: String): SimplePopupWindow {
        findViewById<TextView>(R.id.etMemberNickname).text = content
        return this
    }

    fun setConfirmCallback(listener: OnItemClickListener): SimplePopupWindow {
        clickListener = listener
        return this
    }
}

interface OnItemClickListener {
    fun onClick(popupWindow: SimplePopupWindow)
}